***** H2 - Parents hypothesis

* Produce Figure 3 - AME of household composition on satisfaction with the economy or government's perfomance

		clear all
		
		cd "${data}"	
		
		use data_ess.dta, clear
		
		* Declare survey design for dataset
		svyset, clear 
		svyset country_code [weight=pspwght], strata(essround)

		* Define significance stars for tables
		global stars "+ 0.10 * 0.05 ** 0.01 *** 0.001"
		
		eststo clear
		
		eststo m1: svy: reg stfeco b0.dummy1834 agea income b0.unemployed education unemployment_rate i.essround i.country_code if agea>34 // restricted sample
		eststo m2: svy: reg stfeco  b2.cohabitation_multiple agea income b0.unemployed education unemployment_rate i.essround i.country_code if agea>34 // restricted sample		
		eststo m3: svy: reg stfgov b0.dummy1834 agea income b0.unemployed education unemployment_rate i.essround i.country_code if agea>34 // restricted sample
		eststo m4: svy: reg stfgov  b2.cohabitation_multiple agea income b0.unemployed education unemployment_rate i.essround i.country_code  if agea>34 // restricted sample

	
	* Dummy variable (Top panel)
	
			coefplot m1 m3, vertical keep(*.dummy1834) ///
				plotregion(fcolor(white)) graphregion(fcolor(white)) ///
				ylabel(-0.4(0.05)0.05) yscale(range(-0.4(0.05)0.05))  byopts(row(1)) ///
				aspect(0.5) ///
				ytitle("Effects on linear prediction") ///
				xtitle("Cohabitation with children (binary)") ///
				yline(0, lwidth(thin) lpattern(longdash) lcolor(black)) ///
				p1(label(Economy))    ///
				p2(label(Government)) ///
				msymbol(hallow) levels(95) ///
				title(`i') legend(position(6) row(1)) scheme(plottig) ///
				graphregion(color(white)) plotregion(lcolor(black) lwidth(medthin) margin(zero)) ///
				note("Baseline category:"  "No child living in the household or with children under 18 only") 
		
		graph export ${figures}/Figure3_top_parents.pdf,  replace 
			

	* 5 categories (Bottom panel)		
		
		coefplot m2 m4, vertical keep(*.cohabitation_multiple) ///
				plotregion(fcolor(white)) graphregion(fcolor(white)) ///
				ylabel(-0.4(0.05)0.4) yscale(range(-0.4(0.05)0.4))  byopts(row(1)) ///
				aspect(0.5) ///
				ytitle("Effects on linear prediction") ///
				xtitle("Cohabitation with children (categorical)") ///
				yline(0, lwidth(thin) lpattern(longdash) lcolor(black)) ///
				msymbol(hallow) levels(95) ///
				p1(label(Economy) )    ///
				p2(label(Government) ) ///
				title(`i') legend(position(6) row(1)) scheme(plottig)   ///
				graphregion(color(white)) plotregion(lcolor(black) lwidth(medthin) margin(zero)) ///
				note("Baseline category:" "Ever had children at home but no child currently at home ") 
		
		graph export ${figures}/Figure3_bottom_parents.pdf,  replace 
		
		
			*** Appendix L - Main model - Full Table - Parents hypothesis  
		
		
		esttab m1 m2 m3 m4 using ${tables}/appendixL.tex, ///
		nomtitles booktabs replace ///
		indicate("Country FE = *.country_code" "Year FE = *.essround", labels("\checkmark" "")) ///
		stats(N r2, fmt(%9.0fc %9.2fc) labels("Observations" "R-squared")) ///
		nobaselevels substitute("=1" "") nogap compress nonotes b(2) se(2) starlevels( ${stars}) label mlabels("Model 1" "Model 2" "Model 3" "Model 4" ) 
		
		
		
